
package com.datawin.taotaocheche.ui.adapter;

import android.content.Context;
import android.view.View;

import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

import com.datawin.taotaocheche.R;
import com.datawin.taotaocheche.event.CityEvent;
import com.datawin.taotaocheche.event.DelectEvent;

/**
 * Created by super南仔 on 2017-05-09. 类备注： 需要传入的参数:
 */
public class HeaderAdapter extends SuperBaseAdapter<String> {

    public HeaderAdapter(Context context, List<String> data) {
        super(context, data);
    }

    @Override
    protected void convert(BaseViewHolder holder,final String item, int position) {
        holder.setText(R.id.tvName, item);
        /**
         * 设置可以非滑动触发的开启菜单
         */
        holder.getView(R.id.tvName).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EventBus.getDefault().post(new CityEvent(item));
            }
        });
        holder.getView(R.id.tvName).setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                EventBus.getDefault().post(new DelectEvent(item));
                return false;
            }
        });


    }

    @Override
    protected int getItemViewLayoutId(int position, String item) {
        return R.layout.view_city_header;
    }
}
